<script src="//www.google.com/recaptcha/api.js" async defer
    th:if="${recaptchaSiteKey != null and recaptchaVersion=='v2'}"></script>
<script th:src="${'//www.google.com/recaptcha/api.js?render=' + recaptchaSiteKey}"
    th:if="${recaptchaSiteKey != null and recaptchaVersion == 'v3'}"></script>

<script type="text/javascript" th:src="@{#{webjars.jquery.js}}"></script>
<script type="text/javascript" th:src="@{#{webjars.material-components.js}}"></script>

<script type="text/javascript" th:src="@{${#themes.code('cas.standard.js.file')}}"></script>

<script th:inline="javascript">
    resourceLoadedSuccessfully();
</script>

<script th:inline="javascript">
    /*<![CDATA[*/

    var trackGeoLocation = /*[[${trackGeoLocation}]]*/ === "true";

    var googleAnalyticsTrackingId = /*[[${googleAnalyticsTrackingId}]]*/;

    if (googleAnalyticsTrackingId != null && googleAnalyticsTrackingId != '') {
        (function (i, s, o, g, r, a, m) {
            i['GoogleAnalyticsObject'] = r;
            i[r] = i[r] || function () {
                (i[r].q = i[r].q || []).push(arguments)
            }, i[r].l = 1 * new Date();
            a = s.createElement(o),
                m = s.getElementsByTagName(o)[0];
            a.async = 1;
            a.src = g;
            m.parentNode.insertBefore(a, m)
        })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');

        ga('create', googleAnalyticsTrackingId, 'auto');
        ga('send', 'pageview');
    }

    /*]]>*/
</script>

<span th:if="${recaptchaVersion=='v2'}" th:remove="tag">
    <script type="text/javascript" th:if="${recaptchaSiteKey != null AND recaptchaInvisible != null AND recaptchaInvisible}" th:inline="javascript">
        function onRecaptchaV2Submit(token) {
            document.getElementById('fm1').submit();
        }
    </script>
</span>

<span th:if="${recaptchaVersion=='v3'}" th:remove="tag">
    <script type="text/javascript" th:if="${recaptchaSiteKey != null}" th:inline="javascript">
        grecaptcha.ready(function () {
            grecaptcha.execute(/*[[${recaptchaSiteKey}]]*/, { action: 'login' })
                .then(function (token) {
                    document.getElementById('g-recaptcha-token').value(token)
                });
        });
    </script>
</span>
